<template>
	<orh-table reload  @on-reload="refresh" search :searchOption="typelist"  :searchOptionSelected="searchOptionSelected" @on-search="searchmt"  pages :pageDate="pageDate" @on-page-change="queryData">
		<Table
			:data="datalist"
			:columns="columns1"
			slot="table"
			:loading="tableload"></Table>
	</orh-table>
</template>

<script>
  export default {
    name: "teacher-otherinformation",
    data () {
		return {
			searchOptionSelected: '1',
			typelist: [
				{
					value: '1' ,
					label: '姓名',    
				},
				{
					value: '2' ,
					label: '身份证号',    
				},
			],

			listUrl:'api/teacher/v1/teacher/other_teacher?page=',
			pageDate:{
				total:0,
				current_page:1,
				per_page:10
			},
			tableload:false,
			datalist:[],
			
			columns1: [
				{
					title: "身份证号",
					key: "idcard"
				},
				{
					title: "姓名",
					render:(h,params)=> {
                        return h('span',params.row.teacher_name?params.row.teacher_name.zh?params.row.teacher_name.zh:params.row.teacher_name.mn:'')
                    }
				},
				{
					title: "性别",
					render:(h,params)=> {
                        return h('span',params.row.gender.zh?params.row.gender.zh:params.row.gender.mn)
                    }
				},
				{
					title: "民族",
					render:(h,params)=> {
                        return h('span',params.row.nation.zh?params.row.nation.zh:params.row.nation.mn)
                    }
				},
				{
					title: "联系号码",
					key: "telnumber"
				},

			],
		}
    },
    methods: {
        /************************************************************
         * 
         * 请求列表数据
         * 
         ************************************************************/
        queryData(index=1){
            this.tableload = true 
            this.$http.get(`${this.listUrl}${index}`)
            .then(val=>{   
                this.datalist=val.data
                if(val.pages){
                    this.pageDate.total=val.pages.total
                    this.pageDate.per_page=val.pages.per_page
                    this.pageDate.current_page=val.pages.current_page
                }
                this.tableload = false            
            })
            .catch(err=>{
                if(err.code && err.code==422) {
                    this.$Message.error(err.message);
                }
                this.tableload = false;
            })
		}, 
		
        /************************************************************
         * 
         * 搜索
         * 
         ************************************************************/
		searchmt(str,val) {
			this.listUrl=`api/teacher/v1/teacher/other_teacher?type=${val}&searchvalue=${str}&page=`,
			this.queryData()
		},
        /************************************************************
         * 
         * 刷新
         * 
         ************************************************************/
		refresh(){
			this.queryData(this.pageDate.current_page)
		},

    },
    mounted(){
      	this.queryData()
    }
}
</script>




